package com.ruoyi.mes.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mes.domain.LnyProInventory;
import com.ruoyi.mes.service.ILnyProInventoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库存总览Controller
 * 
 * @author CFL
 * @date 2024-04-28
 */
@RestController
@RequestMapping("/mes/inventory")
public class LnyProInventoryController extends BaseController
{
    @Autowired
    private ILnyProInventoryService lnyProInventoryService;

    /**
     * 查询库存总览列表
     */
    @PreAuthorize("@ss.hasPermi('mes:inventory:list')")
    @GetMapping("/list")
    public TableDataInfo list(LnyProInventory lnyProInventory)
    {
        startPage();
        List<LnyProInventory> list = lnyProInventoryService.selectLnyProInventoryList(lnyProInventory);
        return getDataTable(list);
    }

    /**
     * 导出库存总览列表
     */
    @PreAuthorize("@ss.hasPermi('mes:inventory:export')")
    @Log(title = "库存总览", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LnyProInventory lnyProInventory)
    {
        List<LnyProInventory> list = lnyProInventoryService.selectLnyProInventoryList(lnyProInventory);
        ExcelUtil<LnyProInventory> util = new ExcelUtil<LnyProInventory>(LnyProInventory.class);
        util.exportExcel(response, list, "库存总览数据");
    }

    /**
     * 获取库存总览详细信息
     */
    @PreAuthorize("@ss.hasPermi('mes:inventory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(lnyProInventoryService.selectLnyProInventoryById(id));
    }

    /**
     * 新增库存总览
     */
    @PreAuthorize("@ss.hasPermi('mes:inventory:add')")
    @Log(title = "库存总览", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LnyProInventory lnyProInventory)
    {
        return toAjax(lnyProInventoryService.insertLnyProInventory(lnyProInventory));
    }

    /**
     * 修改库存总览
     */
    @PreAuthorize("@ss.hasPermi('mes:inventory:edit')")
    @Log(title = "库存总览", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LnyProInventory lnyProInventory)
    {
        return toAjax(lnyProInventoryService.updateLnyProInventory(lnyProInventory));
    }

    /**
     * 删除库存总览
     */
    @PreAuthorize("@ss.hasPermi('mes:inventory:remove')")
    @Log(title = "库存总览", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lnyProInventoryService.deleteLnyProInventoryByIds(ids));
    }
}
